<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{:__('document_print')}</title>
    <style>
       body {
            font-size: 14px;
            color: #000;
        }

        ul,
        li,
        table,
        td,
        th,
        tr,
        a {
            margin: 0;
            padding: 0;
        }

        .main {
            width: 790px;
            margin: 35px auto;
        }

        .title {
            font-size: 16px;
            text-align: center;
        }

        .company {
            font-size: 16px;
            text-align: center;
            font-weight: bold;
        }

        .type {
            padding: 5px 10px;
        }

        .type0 {
            float: left;
            width: 20%;
            text-align: left;
        }

        .type5 {
            float: left;
            width: 20%;
            text-align: left;
        }

        .type22 {
            float: left;
            width: 50%;
            text-align: left;
        }

        .type1 {
            float: left;
            width: 20%;
            text-align: left;
        }

        .type11 {
            float: left;
            width: 28%;
            text-align: left;
        }

        .type2 {
            float: left;
            width: 12%;
            text-align: right;
        }

        .type4 {
            float: left;
            width: 13%;
            text-align: right;
        }

        .clear {
            clear: both;
        }

        table {
            border: 1px solid #000;
            width: 100%;
            border-collapse: collapse
        }

        td {
            border: 1px solid #000;
            padding: 1px 5px;
        }

        .t1 {
            font-weight: bold;
            text-align: center;
        }

        .text-center {
            text-align: center;
        }

        .text-right {
            text-align: right;
        }

        .type3 {
            float: left;
            width: 35%;
            text-align: left;
        }

        .infos {
            padding: 5px 10px;
        }

        .border1 {
            position: relative;
        }

        .border1 span {
            position: absolute;
            bottom: 0;
            left: 80px;
            width: 100px;

            border-bottom: 1px solid #000;
        }
    </style>
    <style>
        /*纯CSS写法*/
        .checkbox-group input {
            display: none;
            opacity: 0;
        }

        .checkbox-group input[type=checkbox]+label,
        .checkbox-group input[type=radio]+label {
            line-height: 1;
            position: relative;
            margin: 2px;
        }

        .checkbox-group input[type=checkbox]+label:before,
        .checkbox-group input[type=radio]+label:before {
            line-height: 20px;
            display: inline-block;
            width: 18px;
            height: 18px;
            margin-right: 8px;
            content: '';
            color: #fff;
            border: 1px solid #dce4e6;
            background-color: #f3f6f8;
            border-radius: 3px;
        }

        .checkbox-group input[type=checkbox]:checked+label:before,
        .checkbox-group input[type=radio]:checked+label:before {
            content: '\2713';
            color: #fff;
            background-color: #31b968;
            border-radius: 3px;
            font-size: 23px;
            text-align: center;
            border-color: #000000;
        }

        .noprint {
            display: none;
        }

        .print_btn,
        #close_btn {
            display: none;
        }

        @page {
            margin-bottom: 0mm;
            margin-top: 0mm
        }
    </style>
</head>

<body>
    <div>
        <input type="button" class="print_btn" onclick="preview(1)" value="{:__('print')}">
        <a id="close_btn"
            href="javascript:window.opener=null;window.open('','_self');window.close();">{:__('close')}</a>
    </div>
    <!--startprint-->

    <div>
        <div>
            <input type="button" class="print_btn" onclick="preview(1)" value="{:__('print')}">
            <a id="close_btn"
                href="javascript:window.opener=null;window.open('','_self');window.close();">{:__('close')}</a>
        </div>
        <!--startprint-->
        <div>
            <div style="position: absolute; top: 20px; left: 40px;">
                <img src="/assets/img/print-logo.png" alt="Logo" style="width: 150px; height: auto;">
            </div>
            {volist name="list" id="vo"}
            <div class="main" {if condition='$i<sizeof($list)' }style="page-break-after: always" {/if}>
                <!-- <div class="company">{$company_name|default=''}</div>
            <div class="title">{:__('sales_title')}</div> -->
                <div class="type">
                    <div class="type22">{:__('company_name')}：{$vo.customers.customer_name|default=''}</div>
                    <div class="type0">{:__('purchase_order_type')}：{if
                        condition="$vo.purchase_type==1"}{:__('sales')}{else/}{:__('return')}{/if}</div>
                    <div class="type22">{:__('connect_name')}：{$vo.customers.connet_name|default=''}</div>
                    <div class="type22">{:__('document_date')}：{$vo.purchase_time|date='Y-m-d',###}</div>
                    <!-- <div class="type22">{:__('surname')}：</div> -->
                    <div class="type22">{:__('document_number')}：{$vo.purchase_code|default=''}</div>
                    <div class="type22">{:__('mobile')}：{$vo.customers.customer_mobile|default=''}</div>
                    <div class="type0">{:__('currency')}：{$base_currency | default='GNF'}</div>
                    <div class="clear"></div>
                </div>
                <div>
                    <table>
                        <tr class="t1">
                            <td width="50px">{:__('serial_number')}</td>
                            <td width="250px">{:__('product')}</td>
                            <td width="50px">{:__('unit')}</td>
                            <td width="80px">{:__('quantity')}</td>
                            <td width="80px">{:__('sales_unit_price')}</td>
                            <!-- <td width="100px">{:__('discount_rate')}</td> -->
                            <!-- <td width="80px">{:__('discount_amount')}</td> -->
                            <td width="100px">{:__('sales_amount')}</td>
                            <!-- <td width="100px">{:__('warehouse')}</td> -->
                        </tr>
                        {foreach name="vo.purchase_info" item="info" key="k"}
                        <tr>
                            <td width="50px" class="text-center">{$k+1}</td>
                            <td width="250px">{$info.goods.goods_name|default=''}</td>
                            <td width="50px">{$info.unit.name|default=''}</td>
                            <td width="80px" class="text-center">{$info.number|default=''}</td>
                            <td width="80px" class="text-center">{$info.tax_included|default=''} {$base_currency |
                                default='GNF'}</td>
                            <!-- <td width="80px" class="text-right">{$info.discount|default=''}</td> -->
                            <!-- <td width="80px" class="text-right">{$info.dis_money|default=''}</td> -->
                            <td width="100px" class="text-center">{$info.money_tax_price|default=''} {$base_currency |
                                default='GNF'}</td>
                            <!-- <td width="150px;">{$info.stores.name|default=''}</td> -->
                        </tr>
                        {/foreach}
                        {php}for($a=$k+2;$a<9;$a++){ {/php} <tr>
                            <td width="50px" class="text-center">{$a}</td>
                            <td width="250px"></td>
                            <td width="50px"></td>
                            <td width="80px" class="text-center"></td>
                            <td width="80px" class="text-center"></td>
                            <td width="80px" class="text-center"></td>
                            <!-- <td width="80px" class="text-right"></td>
                            <td width="100px" class="text-right"></td> -->
                            <!-- <td width="150px"></td> -->
                            </tr>
                            {php}}{/php}
                            <!-- <tr>
                                <td colspan="3" class="text-right">{:__('total')}</td>
                                <td width="80px" class="text-right">{$vo.print_number|default=''}</td>
                                <td width="80px" class="text-right"></td>
                                <td width="80px" class="text-right"></td>
                                <td width="80px" class="text-right"></td>
                                <td width="100px" class="text-right">{$vo.print_money|default=''}</td>
                                <td width="150px"></td> 
                            </tr>--> 
                            <!-- <tr>
                        <td colspan="9">{:__('total_capital')}{$vo.print_money_c|default=''}</td>
                    </tr> -->
                    </table>
                </div>
                <br />
                <table>
                    <tr>
                        <td width="50px" class="text-center">{:__('total')}</td>
                        <td width="150px" class="text-center">{$vo.print_money|default=''} {$base_currency |
                            default='GNF'}</td>
                        <!-- <td width="150px"></td> -->
                    </tr>
                    <tr>
                        <td width="50px" class="text-center">{:__('total_capital')}</td>
                        <td  width="150px" class="text-center">{$vo.print_money_c|default=''}</td>
                    </tr>
                </table>
                <br />
                <table style="width: 350px; float: right;">
            
                    {if condition="$vo.preferential_money > 0"}
                    <tr>
                        <td>{:__('discount_amount')}：{$vo.preferential_money|default=''} {$base_currency | default='GNF'}</td>
                    </tr>
                    <tr>
                        <td>{:__('discounted_amount')}：{$vo.money_tax_price|default=''} {$base_currency | default='GNF'}</td>
                    </tr>
                    {/if}
                   
                    <tr>
                        <td>{:__('total_amount')}：{$vo.print_money|default=''} {$base_currency |
                            default='GNF'}</td>
                    </tr>
                    <tr>
                        <td>{:__('payment_this_time')}：{$vo.pay_money|default=''} {$base_currency |
                            default='GNF'}</td>
                    </tr>
                    <tr>
                        <td>{:__('arrears_this_time')}：{$vo.arrears|default=''} {$base_currency |
                            default='GNF'}</td>
                    </tr>
                </table>
    
                <!-- <div class="infos">{:__('remark')}：{$vo.note|default=''}</div> -->
                <div class="type">
                    <div class="type3">{:__('preparer')}：{$vo.preparation.username|default=''}</div>
                    <div class="type3 border1">{:__('shipper_signature')}：<span></span></div>
                    <div class="type3 border1">{:__('customer_signature')}：<span></span></div>
                    <div class="clear"></div>
                </div>
            </div>
            {/volist}
        </div>
        <!-- 页面底部区域 -->
        <div style="text-align: center; margin-top: 50px; position: fixed; bottom: 20px; width: 100%;">
            <p style="margin: 5px 0;">Address:{$company_address|default=''}- Tels: {$company_phone|default=''}- Email:
                3caimans@gmall.com</p>
            <p style="margin: 5px 0;">Site:https://www.3caimans.com - Facebook: 3caimans Shop</a></p>
            <p style="margin: 5px 0;">Merci de nous avoir choisi</p>

        </div>
        <!--endprint-->
        <script>
           bdhtml = window.document.body.innerHTML;
        // 打印开始的标志
        sprnstr = "<!--startprint-->";
        // 打印结束的标志
        eprnstr = "<!--endprint-->";
        // 从打印开始的位置截取到末尾
        prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
        // 从开始截取到打印结束的位置
        prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
        // 替换html
        window.document.body.innerHTML = prnhtml;
        // 打印
        HKEY_Root = "HKEY_CURRENT_USER";
        HKEY_Path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
        try {
            var Wsh = new ActiveXObject("WScript.Shell");
            HKEY_Key = "header";
            //设置页眉（为空） 根据你自己要设置的填入
            Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "");
            HKEY_Key = "footer";
            //设置页脚（为空） 根据你自己要设置的填入
            Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "");
            HKEY_Key = "margin_bottom";
            //设置下页边距（0） 根据你自己要设置的填入
            Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
            HKEY_Key = "margin_left";
            //设置左页边距（0） 根据你自己要设置的填入
            Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "1");
            HKEY_Key = "margin_right";
            //设置右页边距（0）
            Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
            HKEY_Key = "margin_top";
            //设置上页边距（8）
            Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "1");
        } catch (e) { }
        window.print();
        window.document.body.innerHTML = bdhtml;
        var beforePrint = function () {
            //window.print监听打印确认取消
            console.log('Functionality to run before printing.');
        };
        var afterPrint = function () {
            console.log('Functionality to run after printing');
            document.getElementById('close_btn').click();
        };
        if (window.matchMedia) {
            var mediaQueryList = window.matchMedia('print');
            mediaQueryList.addListener(function (mql) {
                if (mql.matches) {
                    beforePrint();
                } else {
                    afterPrint();
                }
            });
        }
        window.onbeforeprint = beforePrint;
        window.onafterprint = afterPrint;
        </script>
</body>

</html>